package main

import (
	"github.com/gofiber/fiber/v2"
	"github.com/gofiber/fiber/v2/middleware/logger"
	"github.com/gofiber/fiber/v2/middleware/monitor"
	log "github.com/sirupsen/logrus"
)

func main() {
	app := fiber.New()

	// 设置日志中间件
	app.Use(logger.New(logger.Config{Format: "${pid} ${locals} ${status} - ${method} ${path}\n"}))

	// 创建GET Request请求，并设置Handler
	app.Get("/", func(ctx *fiber.Ctx) error {
		return ctx.SendString("Hello fiber!")
	})

	// 开启监控面板
	app.Get("/dashboard", monitor.New())

	// 监听端口
	err := app.Listen(":8080")
	if err != nil {
		log.Errorf("服务启动失败: %s", err.Error())
	}
}
